package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.pojo.DtsRegion;
import com.qf.service.ShoppingMallService;
import com.qf.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

/**
 * @author jiangjingbo
 * @version V1.0
 * @Project java2203
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/21 10:27
 */

/**
 * 行政区域
 */
@RestController
@CrossOrigin("*")
@RequestMapping("/region")
public class    ShoppingMallContorller {
    @Autowired
    private ShoppingMallService shoppingMallService;
    @GetMapping("/list")
    public Object list(
            @RequestParam(defaultValue = "1") Integer page ,
            @RequestParam(defaultValue = "20") Integer limit,
            String name,
            Integer code){
        IPage<DtsRegion> all = shoppingMallService.findAll(page, limit, name, code);
        List<DtsRegion> records = all.getRecords();
        long total = all.getTotal();
        HashMap<String, Object> data = new HashMap<>();
        data.put("total",total);
        data.put("items",records);
        return ResponseUtil.ok(data);
    }
}
